/* 2017-9-28 16:04:24  */
//模块：
LArk.widget.bindClass(LArk.widget.BaseWidget.extend({
    options: {
        //弹窗
        view: {
            type: "window",
            url: "view.html",
            windowOptions: {
                width: 340,
                height: 280
            }
        },
    },
    //初始化[仅执行1次]
    create: function () {

    },
    viewWindow: null,
    drawEntity: null,
    floodControl: null,
    //每个窗口创建完成后调用
    winCreateOK: function (opt, result) {
        this.viewWindow = result;
    },
    //打开激活
    activate: function () {

    },
    onStart: null,
    currentHeight: 0,
    beginFlood: function (minValue, maxValue, speed) {
        var that = this;

        var positions = that.viewer.LArkgis.draw.getPositions(that.drawEntity);
        that.viewer.LArkgis.draw.deleteAll(), that.drawEntity = null;
        that.floodControl = new LArk.analysi.TerrainFlood(that.viewer, {
            positions: positions,
            minHeight: minValue,
            maxHeight: maxValue,
            speed: speed,
            visibleOutArea: false,
            onChange: function (height) {
                that.viewWindow.computeCurrentHeight(height)
            },
            onStop: function () {
                that.viewWindow.onStop();
                console.log(that.floodControl.floodAnalysis)
            }
        });
        
    },
    drawPolygon: function () {
        var that = this;
        that.viewer.LArkgis.draw.deleteAll();
        that.viewer.LArkgis.draw.startDraw({
            type: "polygon",
            style: {
                color: "#007be6",
                opacity: 0.5,
                perPositionHeight: true,
                outline: false
            },
            success: function (entity) { //绘制成功后回调
                that.drawEntity = entity;
                haoutil.loading.show();
                //求最大、最小高度值  
                var positions = that.viewer.LArkgis.draw.getPositions(entity)
                var result = LArk.point.computePolygonHeightRange(positions, that.viewer.scene);
                that.viewWindow.computePolygonH(result)

                haoutil.loading.hide();
            }
        });
    },
    clear: function () {
        this.floodControl && this.floodControl.destroy();
        this.viewer.LArkgis.draw.deleteAll();
        this.drawEntity = null;
    },
    //关闭释放
    disable: function () {
        this.viewWindow = null;
        this.clear();

    },


}));
